<?php

class ArticleTable extends Doctrine_Table
{
	public function getActiveArticles(){
		$q =Doctrine_Query::create()
		  ->select('a.id, a.titre')
		  ->from ('article as a')
		  ->where ('a.etat=?',1)
		  ->andWhere('a.dateexpiration >?',time())
		  ->orderby('a.titre');
		
		return $q->execute();
	}
	
	public function getIdRubrique($id=null){
		$q =Doctrine_Query::create()
		  -> select('a.id, a.etat, a.rubriqueid')
		  -> from ('article as a')
		  -> where('a.etat=?',1)
		  -> andWhere('a.id=?', $id);
			
		return $q->execute();
	}
	
	public function activeDeactiveArticle($valeur,$etat){
		$q = Doctrine_Query::create()
		  -> update('article')
		  -> set('etat=?',$etat)
		  -> where('id =?', $valeur);
		  
		return $q->execute();
	}
}